<%@page import="monster.comm.util.SpringApplicationContextFactory"%>
<%@page import="monster.flight.admin.manager.service.admin.Flight_infoService"%>
<%@page import="monster.flight.comm.util.FlightFactory"%>
<%@page import="monster.comm.util.DateUtil"%>
<%@page import="monster.flight.comm.entity.vo.FlightBay"%>
<%@page import="sun.jdbc.rowset.CachedRowSet"%>
<%@page import="monster.flight.comm.entity.vo.Flight_info"%>
<%@page import="monster.comm.database.DBManager"%>
<%@page import="monster.comm.util.SysConstant"%>
<%@page import="monster.comm.util.UserService"%>
<%@page import="monster.comm.util.Tool"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String now_time=Tool.getRequest("now_time",request);//必传参数
String squadron_no=Tool.getRequest("squadron_no",request);//所在中队
String unit_no=Tool.getRequest("unit_no",request);//所在分队
if(now_time.length()==0){
	out.println("{\"id\":-101,\"now_time\":\"你还没有选择时间！\"}");
	return;
}
String list="";
String flight_date = DateUtil.getDate("yyyy-MM-dd");
UserService user = (UserService) session.getAttribute(SysConstant.SESSION_NAME);//获得session里面的登陆信息
if(1==2){
	out.println("{\"id\":-100,\"name\":\"没有登录\"}");
	return;
}else{
	try{
		DBManager db = new DBManager();
		String sql = "SELECT a.CUR_DAY_WORKNUM,a.TOTAL_WORKNUM,b.STAFF_NAME,b.POSITION FROM STAFF_DAY_WORK A JOIN STAFF_INFO B ON A.STAFF_SN=B.STAFF_SN "
					+"   WHERE b.UNIT_NO='"+unit_no+"' and  b.SQUADRON_NO='"+squadron_no+"' and a.WORK_DATE= '"+flight_date+"' order by b.POSITION";					
		CachedRowSet cr = db.getRowSet(sql);
		StringBuilder sb = new StringBuilder(200);
		Map<String,String> map = new HashMap<String,String>();
		map.put("1","机械");
		map.put("2","放行");
		map.put("3","上岗");
		map.put("4","学徒");
		int i=1;
		while(cr.next()){
			String cur_day_worknum = Tool.getRsValue(cr,"CUR_DAY_WORKNUM");
			String total_worknum = Tool.getRsValue(cr,"TOTAL_WORKNUM");
			String staff_name = Tool.getRsValue(cr,"STAFF_NAME");
			String position = Tool.getRsValue(cr,"POSITION");
			position = map.get(position);
			sb.append("{\"staff_name\":\"").append(staff_name).append("\",")
			.append("\"position\":\"").append(position).append("\",")
			.append("\"cur_day_worknum\":\"").append(cur_day_worknum).append("\",")
			.append("\"total_worknum\":\"").append(total_worknum).append("\"")
			.append("}");
			if(i++<cr.size()){
				sb.append(",");
			}
		}		
		 list="{\"id\":100,\"list\":["+sb.toString()+"]}";
	}catch(Exception e){
		 e.printStackTrace();
		 list="{\"id\":-200,\"name\":\"程序异常\"}";
	}
	
	out.println(list);

}
%>
